package com.treasure.service.collocate.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.annotation.NoLogin;
import com.treasure.service.collocate.service.BannerService;
import com.treasure.service.domain.TBanner;
import com.treasure.service.dto.TBannerDto;
import com.treasure.service.enums.CodeEnum;
import com.treasure.service.result.PageResult;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: banner信息维护
 * @version 1.0
 * @author panxinwen 2018/10/30 10:32
 * @Copyright © 2015 | 武汉京航科技有限公司 Email:19919866605@163.com
 * */
@Api(value = "banner信息维护",description = "banner信息维护")
@RestController
@RequestMapping("/banner/v1")
public class BannerController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private BannerService bannerService;

//    @NoLogin
    @ApiOperation(value = "获取banner列表", notes = "获取banner列表")
    @PostMapping("/getBannerList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "頁碼", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每頁顯示數量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "当前状态(0-禁用 1-启用)", required = true, dataType = "int", paramType = "query"),
    })
    @LogInfo(log = "获取banner列表",isPrint = true)
    public ResponseEntity getBannerList(@RequestParam(value = "pageSize") Integer pageSize,
                                         @RequestParam(value = "pageNum") Integer pageNum,
                                         @RequestParam(value = "status",required = false) Integer status
    ){

        PageResult<List<TBannerDto>> result = bannerService.getBannerList(pageSize,pageNum,status);

        return ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,result));

    }

}
